tools/oxenstored: Only quit on SIGTERM when a reload is possible
authorEdwin Török <edvin.torok@citrix.com>
Fri, 8 Jan 2021 11:57:37 +0000 (11:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Jan 2021 14:55:10 +0000 (14:55 +0000)
commite663158bca89aa81ea567befc7c0f742568a6194
tree4639b203e81225039e7db660c8e6539bcf615054
parent5e317896342d553f0b55f72948bbf93a0f1147d3
tools/oxenstored: Only quit on SIGTERM when a reload is possible

Currently when oxenstored receives SIGTERM it dumps its state and quits.  It
is possible to then restart it if --restart is given, however that is not
always safe:

* Domains could have active transactions, and after a restart they would
  either reuse transaction IDs of already open transactions, or get an error
  back that the transaction doesn't exist

* There could be pending data to send to a VM still in oxenstored's
  queue which would be lost

* There could be pending input to be processed from a VM in oxenstored's
  queue which would be lost

Prevent shutting down oxenstored via SIGTERM in the above situations.  Also
ignore domains marked as bad because oxenstored would never talk to them
again.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Reviewed-by: Pau Ruiz Safont <pau.safont@citrix.com>
Reviewed-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/xenstored/connection.ml
tools/ocaml/xenstored/connections.ml
tools/ocaml/xenstored/xenstored.ml